package com.esd.common.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一返回类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
    private Integer code ;
    private String msg;
    private Object data;

    public static R ok(Object data){
        if (data instanceof String){
            return new R(0,
                    data.toString(),null);
        }
        return new R(0, "操作成功!!" , data);
    }
    public static R ok(){
        return R.ok(null);
    }
    public static R error(String message){
        return new  R(500, message ,null);
    }
    public static R error(){
        return new R(500,"操作失败!!",null);
    }
}